package com.yuexiao.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yuexiao.entity.ResultInfo;
import com.yuexiao.pojo.Category;
import com.yuexiao.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName:CategoryController
 * @Auther: YUEXIAO
 * @Description: 类别操作控制器
 * @Date: 2022/8/11 18:47
 * @Version: v1.0
 */
@RestController
@Slf4j
@RequestMapping("/category")
public class CategoryController {

    @Reference
    private CategoryService categoryService;

    /**
     * 查询所有分类数据
     * @return ResultInfo 返回结果对象
     */
    @GetMapping("/getAll")
    @PreAuthorize("hasAnyRole('ROLE_NOMAL')")
    public ResultInfo getAll(){
        return ResultInfo.success(categoryService.getAllCategory());
    }

}
